package de.fhffm.scs.simulator.hardware;

import de.fhffm.scs.simulator.body.Body;
import de.fhffm.scs.simulator.data.BloodSugarLevel;
import de.fhffm.scs.simulator.scheduler.Scheduler;

/**
 * This class represents a simulated hardware sensor and serves as a bridge
 * between drivers and a body body.
 * 
 * @author claudio, tatiana
 * 
 */
public class Sensor2000Impl implements SensorHardware {

	private Body body;
	private Scheduler scheduler;

	public Sensor2000Impl(Body h, Scheduler scheduler) {
		this.scheduler = scheduler;
		if (h == null) {
			throw new IllegalArgumentException();
		}
		body = h;
	}

	@Override
	public BloodSugarLevel getBloodSugarLevel() {
		BloodSugarLevel bsl = meassureBloodSugarLevel();
		return bsl;
	}

	private BloodSugarLevel meassureBloodSugarLevel() {
		long currentTimestamp = scheduler.getCurrentTimestamp();
		return new BloodSugarLevel(body.getBloodSugarLevel(),
				currentTimestamp);
	}

	@Override
	public Body getHuman() {
		return body;
	}

}
